habari: convert url to link

The only feature I was missing in habari was tha automatic conversion of urls to clickable links. I googled and found the following code snippet: http://codesnippets.joyent.com/posts/show/2104. To use this in your habari theme, insert the following into your theme.php:

	public function filter_comment_content_out($content){
	$pattern = "@\b(https?://)?(([0-9a-zA-Z_!~*'().&=+$%-]+:)?[0-9a-zA-Z_!~*'().&=+$%-]+\@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\@&=+$,%#-]+)*/?)@";
	return preg_replace($pattern, '\0', $content);
	 }

After this is done all the urls typed in the commentbox will be displayed as clickable links.

Iratkozz fel, hogy elsőnek értesülj új bejegyzésekről:

2 responses to “habari: convert url to link”

  1. Galamb Avatar
    Galamb

    google.css-be mintha hiányozna a pre.prettyprint -hez egy overflow: auto, mert így egy pöppet csúnya 😛

  2. kobak Avatar

    Jogos. Majd beteszem, aztán megírom a nagy plugin kezelőnek. Köszönöm. Sajnos az utóbbi időben nem sok idő jutott a blogra.

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)